package com.uniflow.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 表单实体类
 */
@ApiModel(description = "表单")
@TableName("forms")
public class Form {
    
    @ApiModelProperty("表单ID")
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;
    
    @ApiModelProperty("表单名称")
    @TableField("name")
    private String name;
    
    @ApiModelProperty("表单标题")
    @TableField("title")
    private String title;
    
    @ApiModelProperty("表单描述")
    @TableField("description")
    private String description;
    
    @ApiModelProperty("表单分类")
    @TableField("category")
    private String category;
    
    @ApiModelProperty("表单配置JSON")
    @TableField("config_json")
    private String configJson;
    
    @ApiModelProperty("表单字段JSON")
    @TableField("fields_json")
    private String fieldsJson;
    
    @ApiModelProperty("表单样式JSON")
    @TableField("style_json")
    private String styleJson;
    
    @ApiModelProperty("表单版本")
    @TableField("version")
    private Integer version;
    
    @ApiModelProperty("是否发布")
    @TableField("is_published")
    private Boolean published;
    
    @ApiModelProperty("是否启用")
    @TableField("is_enabled")
    private Boolean enabled;
    
    @ApiModelProperty("排序")
    @TableField("sort_order")
    private Integer sortOrder;
    
    @ApiModelProperty("状态")
    @TableField("status")
    private String status;
    
    @ApiModelProperty("外部ID")
    @TableField("external_id")
    private String externalId;
    
    @ApiModelProperty("创建人ID")
    @TableField("created_by")
    private String createdBy;
    
    @ApiModelProperty("创建人姓名")
    @TableField("created_by_name")
    private String createdByName;
    
    @ApiModelProperty("更新人ID")
    @TableField("updated_by")
    private String updatedBy;
    
    @ApiModelProperty("更新人姓名")
    @TableField("updated_by_name")
    private String updatedByName;
    
    @ApiModelProperty("创建时间")
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    @ApiModelProperty("更新时间")
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;
    
    // 扩展字段（不存储到数据库）
    
    @ApiModelProperty("表单字段列表")
    @TableField(exist = false)
    private List<FormField> fields;
    
    @ApiModelProperty("表单配置")
    @TableField(exist = false)
    private FormConfig config;
    
    @ApiModelProperty("表单样式")
    @TableField(exist = false)
    private FormStyle style;
    
    @ApiModelProperty("使用次数")
    @TableField(exist = false)
    private Integer usageCount;
    
    @ApiModelProperty("最后使用时间")
    @TableField(exist = false)
    private LocalDateTime lastUsedAt;
    
    // Getters and Setters
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getCategory() {
        return category;
    }
    
    public void setCategory(String category) {
        this.category = category;
    }
    
    public String getConfigJson() {
        return configJson;
    }
    
    public void setConfigJson(String configJson) {
        this.configJson = configJson;
    }
    
    public String getFieldsJson() {
        return fieldsJson;
    }
    
    public void setFieldsJson(String fieldsJson) {
        this.fieldsJson = fieldsJson;
    }
    
    public String getStyleJson() {
        return styleJson;
    }
    
    public void setStyleJson(String styleJson) {
        this.styleJson = styleJson;
    }
    
    public Integer getVersion() {
        return version;
    }
    
    public void setVersion(Integer version) {
        this.version = version;
    }
    
    public Boolean getPublished() {
        return published;
    }
    
    public void setPublished(Boolean published) {
        this.published = published;
    }
    
    public Boolean getEnabled() {
        return enabled;
    }
    
    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }
    
    public Integer getSortOrder() {
        return sortOrder;
    }
    
    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public String getExternalId() {
        return externalId;
    }
    
    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }
    
    public String getCreatedBy() {
        return createdBy;
    }
    
    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }
    
    public String getCreatedByName() {
        return createdByName;
    }
    
    public void setCreatedByName(String createdByName) {
        this.createdByName = createdByName;
    }
    
    public String getUpdatedBy() {
        return updatedBy;
    }
    
    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }
    
    public String getUpdatedByName() {
        return updatedByName;
    }
    
    public void setUpdatedByName(String updatedByName) {
        this.updatedByName = updatedByName;
    }
    
    public LocalDateTime getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
    
    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }
    
    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }
    
    public List<FormField> getFields() {
        return fields;
    }
    
    public void setFields(List<FormField> fields) {
        this.fields = fields;
    }
    
    public FormConfig getConfig() {
        return config;
    }
    
    public void setConfig(FormConfig config) {
        this.config = config;
    }
    
    public FormStyle getStyle() {
        return style;
    }
    
    public void setStyle(FormStyle style) {
        this.style = style;
    }
    
    public Integer getUsageCount() {
        return usageCount;
    }
    
    public void setUsageCount(Integer usageCount) {
        this.usageCount = usageCount;
    }
    
    public LocalDateTime getLastUsedAt() {
        return lastUsedAt;
    }
    
    public void setLastUsedAt(LocalDateTime lastUsedAt) {
        this.lastUsedAt = lastUsedAt;
    }
    
    // 内部类定义
    
    /**
     * 表单字段
     */
    public static class FormField {
        private String id;
        private String name;
        private String label;
        private String type;
        private String placeholder;
        private String defaultValue;
        private Boolean required;
        private Boolean readonly;
        private Boolean disabled;
        private Integer maxLength;
        private Integer minLength;
        private String pattern;
        private String errorMessage;
        private String helpText;
        private Integer sortOrder;
        private Object options;
        private Object validation;
        private Object style;
        
        // Getters and Setters
        
        public String getId() {
            return id;
        }
        
        public void setId(String id) {
            this.id = id;
        }
        
        public String getName() {
            return name;
        }
        
        public void setName(String name) {
            this.name = name;
        }
        
        public String getLabel() {
            return label;
        }
        
        public void setLabel(String label) {
            this.label = label;
        }
        
        public String getType() {
            return type;
        }
        
        public void setType(String type) {
            this.type = type;
        }
        
        public String getPlaceholder() {
            return placeholder;
        }
        
        public void setPlaceholder(String placeholder) {
            this.placeholder = placeholder;
        }
        
        public String getDefaultValue() {
            return defaultValue;
        }
        
        public void setDefaultValue(String defaultValue) {
            this.defaultValue = defaultValue;
        }
        
        public Boolean getRequired() {
            return required;
        }
        
        public void setRequired(Boolean required) {
            this.required = required;
        }
        
        public Boolean getReadonly() {
            return readonly;
        }
        
        public void setReadonly(Boolean readonly) {
            this.readonly = readonly;
        }
        
        public Boolean getDisabled() {
            return disabled;
        }
        
        public void setDisabled(Boolean disabled) {
            this.disabled = disabled;
        }
        
        public Integer getMaxLength() {
            return maxLength;
        }
        
        public void setMaxLength(Integer maxLength) {
            this.maxLength = maxLength;
        }
        
        public Integer getMinLength() {
            return minLength;
        }
        
        public void setMinLength(Integer minLength) {
            this.minLength = minLength;
        }
        
        public String getPattern() {
            return pattern;
        }
        
        public void setPattern(String pattern) {
            this.pattern = pattern;
        }
        
        public String getErrorMessage() {
            return errorMessage;
        }
        
        public void setErrorMessage(String errorMessage) {
            this.errorMessage = errorMessage;
        }
        
        public String getHelpText() {
            return helpText;
        }
        
        public void setHelpText(String helpText) {
            this.helpText = helpText;
        }
        
        public Integer getSortOrder() {
            return sortOrder;
        }
        
        public void setSortOrder(Integer sortOrder) {
            this.sortOrder = sortOrder;
        }
        
        public Object getOptions() {
            return options;
        }
        
        public void setOptions(Object options) {
            this.options = options;
        }
        
        public Object getValidation() {
            return validation;
        }
        
        public void setValidation(Object validation) {
            this.validation = validation;
        }
        
        public Object getStyle() {
            return style;
        }
        
        public void setStyle(Object style) {
            this.style = style;
        }
    }
    
    /**
     * 表单配置
     */
    public static class FormConfig {
        private String layout;
        private Integer columns;
        private String labelPosition;
        private Integer labelWidth;
        private Boolean showSubmitButton;
        private Boolean showResetButton;
        private String submitButtonText;
        private String resetButtonText;
        private String submitUrl;
        private String submitMethod;
        private Boolean enableValidation;
        private Boolean enableAutoSave;
        private Integer autoSaveInterval;
        
        // Getters and Setters
        
        public String getLayout() {
            return layout;
        }
        
        public void setLayout(String layout) {
            this.layout = layout;
        }
        
        public Integer getColumns() {
            return columns;
        }
        
        public void setColumns(Integer columns) {
            this.columns = columns;
        }
        
        public String getLabelPosition() {
            return labelPosition;
        }
        
        public void setLabelPosition(String labelPosition) {
            this.labelPosition = labelPosition;
        }
        
        public Integer getLabelWidth() {
            return labelWidth;
        }
        
        public void setLabelWidth(Integer labelWidth) {
            this.labelWidth = labelWidth;
        }
        
        public Boolean getShowSubmitButton() {
            return showSubmitButton;
        }
        
        public void setShowSubmitButton(Boolean showSubmitButton) {
            this.showSubmitButton = showSubmitButton;
        }
        
        public Boolean getShowResetButton() {
            return showResetButton;
        }
        
        public void setShowResetButton(Boolean showResetButton) {
            this.showResetButton = showResetButton;
        }
        
        public String getSubmitButtonText() {
            return submitButtonText;
        }
        
        public void setSubmitButtonText(String submitButtonText) {
            this.submitButtonText = submitButtonText;
        }
        
        public String getResetButtonText() {
            return resetButtonText;
        }
        
        public void setResetButtonText(String resetButtonText) {
            this.resetButtonText = resetButtonText;
        }
        
        public String getSubmitUrl() {
            return submitUrl;
        }
        
        public void setSubmitUrl(String submitUrl) {
            this.submitUrl = submitUrl;
        }
        
        public String getSubmitMethod() {
            return submitMethod;
        }
        
        public void setSubmitMethod(String submitMethod) {
            this.submitMethod = submitMethod;
        }
        
        public Boolean getEnableValidation() {
            return enableValidation;
        }
        
        public void setEnableValidation(Boolean enableValidation) {
            this.enableValidation = enableValidation;
        }
        
        public Boolean getEnableAutoSave() {
            return enableAutoSave;
        }
        
        public void setEnableAutoSave(Boolean enableAutoSave) {
            this.enableAutoSave = enableAutoSave;
        }
        
        public Integer getAutoSaveInterval() {
            return autoSaveInterval;
        }
        
        public void setAutoSaveInterval(Integer autoSaveInterval) {
            this.autoSaveInterval = autoSaveInterval;
        }
    }
    
    /**
     * 表单样式
     */
    public static class FormStyle {
        private String theme;
        private String backgroundColor;
        private String borderColor;
        private String borderRadius;
        private String padding;
        private String margin;
        private String fontSize;
        private String fontFamily;
        private String color;
        private Object customCss;
        
        // Getters and Setters
        
        public String getTheme() {
            return theme;
        }
        
        public void setTheme(String theme) {
            this.theme = theme;
        }
        
        public String getBackgroundColor() {
            return backgroundColor;
        }
        
        public void setBackgroundColor(String backgroundColor) {
            this.backgroundColor = backgroundColor;
        }
        
        public String getBorderColor() {
            return borderColor;
        }
        
        public void setBorderColor(String borderColor) {
            this.borderColor = borderColor;
        }
        
        public String getBorderRadius() {
            return borderRadius;
        }
        
        public void setBorderRadius(String borderRadius) {
            this.borderRadius = borderRadius;
        }
        
        public String getPadding() {
            return padding;
        }
        
        public void setPadding(String padding) {
            this.padding = padding;
        }
        
        public String getMargin() {
            return margin;
        }
        
        public void setMargin(String margin) {
            this.margin = margin;
        }
        
        public String getFontSize() {
            return fontSize;
        }
        
        public void setFontSize(String fontSize) {
            this.fontSize = fontSize;
        }
        
        public String getFontFamily() {
            return fontFamily;
        }
        
        public void setFontFamily(String fontFamily) {
            this.fontFamily = fontFamily;
        }
        
        public String getColor() {
            return color;
        }
        
        public void setColor(String color) {
            this.color = color;
        }
        
        public Object getCustomCss() {
            return customCss;
        }
        
        public void setCustomCss(Object customCss) {
            this.customCss = customCss;
        }
    }
}